package com.zut.subject.infra.basic.service.impl;
import com.zut.subject.infra.basic.entity.SubjectCategory;
import com.zut.subject.infra.basic.mapper.SubjectCategoryDao;
import com.zut.subject.infra.basic.service.SubjectCategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 题目分类(SubjectCategory)表服务实现类
 *
 * @author makejava
 * @since 2024-03-01 10:29:04
 */
@Slf4j
@Service("subjectCategoryService")
public class SubjectCategoryServiceImpl implements SubjectCategoryService {

    @Resource
    private SubjectCategoryDao subjectCategoryDao;



    /**
     * 新增数据
     *
     * @param subjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectCategory insert(SubjectCategory subjectCategory) {
        this.subjectCategoryDao.insert(subjectCategory);
        return subjectCategory;
    }


    //通过id查询分类
    @Override
    public SubjectCategory queryById(Integer id) {

        return  this.subjectCategoryDao.queryById(id);

    }

    /**
     * 修改数据
     *
     * @param subjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public int update(SubjectCategory subjectCategory) {
        if (log.isInfoEnabled()){
            log.info("infra向mapper传递数据为：{}",subjectCategory);
        }
        int update = subjectCategoryDao.update(subjectCategory);
        if (log.isInfoEnabled()){
            log.info("mapper向infra返回数据为：{}",update);
        }
        return update;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.subjectCategoryDao.deleteById(id) > 0;
    }

    /**
    查询分类数据
     */
    @Override
    public List<SubjectCategory> queryPrimaryCategory(SubjectCategory subjectCategory) {
        List<SubjectCategory> list=subjectCategoryDao.queryPrimaryCategory(subjectCategory);
        return list;
    }

    @Override
    public Integer queryCount(Integer id) {
        return subjectCategoryDao.queryCount(id);

    }


}
